package org.flik.server.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

@NamedQueries({@NamedQuery(name=Project.FIND_ALL_PROJECTS, query = "select p from Project p order by p.description")})

@SuppressWarnings("serial")
@Entity
public class Project implements Serializable{
	
	public static final String FIND_ALL_PROJECTS = "Project.findAllProjects"; 
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Long id; 
	
	@Column(unique=true, nullable = false)
	private String description;

	@ManyToMany(cascade=CascadeType.ALL)
	@JoinTable(name = "TICKET_CATEGORY_PROJECT", joinColumns = { @JoinColumn(name = "PROJECT_ID", referencedColumnName = "ID") }, inverseJoinColumns = { @JoinColumn(name = "TICKET_CATEGORY_ID", referencedColumnName = "ID") })
	private List<TicketCategory> ticketCategories;

	public Project() {
		// TODO Auto-generated constructor stub
	}
	
	public Project(String description, List<TicketCategory> ticketCategories) {
		super();
		this.description = description;
		this.ticketCategories = ticketCategories;
	}


	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public List<TicketCategory> getTicketCategories() {
		return ticketCategories;
	}

	public void setTicketCategories(List<TicketCategory> ticketCategories) {
		this.ticketCategories = ticketCategories;
	} 
}
